Computing Fundamentals

Today’s Goals

By the end of this session, you’ll be able to:

  • Explain how computers store and process data

  • Describe what an operating system does and why it matters

  • Navigate a file system using the command line

  • Understand the difference between absolute and relative paths

  • Use essential terminal commands for your Python workflow

What Is a Computer?

a programmable usually electronic device that can store, retrieve, and process data

— Merriam-Webster

Three key capabilities:

  • Store — remember information (memory, disk)

  • Retrieve — access stored information

  • Process — transform data according to instructions

🔮 Predict: What Makes a Computer a "Computer"?

Which of these are computers? Discuss with a neighbor.

  • A smartphone

  • A microwave oven

  • A digital thermostat

  • A basic calculator

  • A car’s engine control unit

Turn to a neighbor and discuss for 60 seconds.

All of them! Each can store, retrieve, and process data according to programmable instructions—though some are more general-purpose than others.

Computer Architecture

von Neumann Architecture

Most modern computers follow a design from 1945 called von Neumann architecture.

von neumann
Figure 1. von Neumann Architecture

The Four Essential Components

CPU

Central Processing Unit — executes instructions

Memory

RAM — fast, temporary storage

Storage

Disk/SSD — persistent data

I/O

Input/Output — keyboard, screen, network

When you run a Python program:

  1. Your code loads from storage into memory

  2. The CPU executes each instruction

  3. Results display via I/O (your screen)

The Early Days: Room-Sized Computers

Individual computers were large, analog devices that required teams of people to manage.

ibm
Figure 2. IBM System 360 Model 91 operator’s console

Input: Punch Cards and Tape

Early computers used physical media for input—no keyboards!

reader ibm
Figure 3. IBM 2314 disk drives and IBM 2540 card reader/punch at the University of Michigan

Operating Systems

Why Do We Need Operating Systems?

As computers became more complex, problems arose:

  • How do we run multiple programs at once?

  • How do we let multiple users share one machine?

  • How do we protect data from unauthorized access?

  • How do we manage hardware so programs don’t conflict?

The operating system (OS) solves all of these problems.

What Does an OS Actually Do?

Memory Management

Allocates RAM to programs, prevents conflicts

Process Management

Runs multiple programs, shares CPU time

File System

Organizes data on disk, controls access

Security

Authenticates users, enforces permissions

I/O Management

Handles keyboards, displays, networks

Command Interface

Lets you interact (GUI or command line)

Modern Operating Systems

Windows

Most common for personal computers, gaming

macOS

Apple computers, popular with developers

Linux

Servers, cloud computing, development

iOS/Android

Mobile devices

Fun fact: macOS and Linux are both based on Unix, which is why their terminals are similar!

🔮 Predict: What’s the OS Doing?

When you double-click a Python file to run it, what does the OS do?

Turn to a neighbor and discuss for 60 seconds.

  1. Finds the file on disk (file system)

  2. Loads Python interpreter into memory (memory management)

  3. Loads your script into memory

  4. Gives Python CPU time to run (process management)

  5. Sends output to your terminal (I/O management)

The Terminal

What Is a Terminal?

A text-based interface for interacting with your computer.

terminal
Figure 4. The DEC VT100, a widely emulated computer terminal

Originally, terminals were physical devices connected to mainframes. Today, we use terminal emulators—software that provides the same text interface.

Why Learn the Terminal?

As a Python developer, you’ll use the terminal to:

  • Run Python scripts: python my_script.py

  • Install packages: pip install pandas

  • Manage files: Create, move, delete files and folders

  • Use version control: git commit, git push

  • Access remote servers: Work on cloud machines

The terminal is your power tool.

Opening Your Terminal

Windows

Search for "PowerShell" or "Command Prompt"

macOS

Applications → Utilities → Terminal

Linux

Usually Ctrl+Alt+T, or search "Terminal"

When you open it, you’ll see a prompt waiting for your command:

# Mac/Linux might look like:
username@computer ~ $

# Windows might look like:
PS C:\Users\username>

Anatomy of a Command

command -options arguments
ls -la /home/user/documents

ls

The command (list files)

-la

Options (l=long format, a=show hidden)

/home/user/documents

Argument (which directory to list)

Essential Commands: Navigation

Mac/LinuxWindowsWhat it does

pwd

cd (no args)

Print Working Directory (where am I?)

ls

dir

List files in current directory

cd folder

cd folder

Change Directory (move to folder)

cd ..

cd ..

Go up one level (parent directory)

cd ~

cd %USERPROFILE%

Go to home directory

Note
PowerShell supports both ls and dir, and cd ~ works too!

Essential Commands: File Operations

Mac/LinuxWindowsWhat it does

mkdir folder

mkdir folder

Make a new directory

touch file.txt

New-Item file.txt

Create an empty file

cp src dest

copy src dest

Copy a file

mv src dest

move src dest

Move or rename a file

rm file

del file

Remove (delete) a file

cat file

type file

Display file contents

Common Mistake: rm Is Permanent!

rm important_file.txt    # Gone forever!
rm -r entire_folder/     # Deletes folder AND everything in it!

There is no Trash or Recycle Bin in the terminal. Deleted files are gone immediately.

Tips:

  • Double-check your command before pressing Enter

  • Use ls first to see what you’re about to delete

  • Consider mv file.txt ~/.trash/ as a safer alternative

Try It: Terminal Navigation

Open your terminal and try these commands:

pwd                    # Where are you?
ls                     # What's here?
cd Desktop             # Go to Desktop (or another folder)
pwd                    # Confirm you moved
ls                     # What's on your Desktop?
cd ..                  # Go back up
pwd                    # Confirm you're back

Work through these with a partner. Help each other!

File Systems

The Directory Tree

Files are organized in a hierarchical structure—folders within folders.

/                        ← Root (top of the tree)
├── home/
│   └── alice/           ← Alice's home directory
│       ├── Documents/
│       │   └── essay.txt
│       ├── Downloads/
│       └── projects/
│           └── inst326/
│               └── hw1.py
├── usr/
│   └── bin/
└── etc/

Important: Root vs. Home Directory

Root Directory

The topmost level of the entire file system

Home Directory

Your personal folder (where your files live)

# Root directory
/                    # Mac/Linux
C:\                  # Windows

# Home directory
/home/username       # Linux
/Users/username      # Mac
C:\Users\username    # Windows

The ~ symbol is a shortcut for your home directory.

Paths: Finding Your Files

A path is the address of a file in the file system.

Absolute path: Full address from root

/home/alice/projects/inst326/hw1.py   # Mac/Linux
C:\Users\Alice\projects\inst326\hw1.py # Windows

Relative path: Address from current location

projects/inst326/hw1.py    # If you're in /home/alice
../Documents/essay.txt     # Go up one level, then into Documents

🔮 Predict: Where Do These Paths Lead?

You are in /home/alice/projects. Where do these paths point?

./hw1.py
../Documents
../../bob
/home/alice

Turn to a neighbor and discuss for 60 seconds.

./hw1.py           # /home/alice/projects/hw1.py
../Documents       # /home/alice/Documents
../../bob          # /home/bob
/home/alice        # /home/alice (absolute, ignores current location)

Why Paths Matter for Python

When you work with files in Python, you need correct paths:

# This only works if data.txt is in the current directory
with open("data.txt", "r") as f:
    content = f.read()

# This works from anywhere (absolute path)
with open("/home/alice/projects/data.txt", "r") as f:
    content = f.read()

# This works if you're in the project's parent directory
with open("my_project/data.txt", "r") as f:
    content = f.read()

Tip: Use pwd to check where Python thinks you are!

Try It: Path Practice

From your home directory, figure out:

  1. The absolute path to your Desktop

  2. The relative path from Desktop to Documents

  3. What cd ~/Documents/../Downloads would do

# 1. Absolute path to Desktop
/Users/yourname/Desktop        # Mac
/home/yourname/Desktop         # Linux
C:\Users\yourname\Desktop      # Windows

# 2. Relative from Desktop to Documents
../Documents

# 3. cd ~/Documents/../Downloads
# Goes to home, then Documents, then up, then Downloads
# Ends up in ~/Downloads (the long way!)

Files and Formats

What Is a File?

A file is packaged data with:

  • A name (including extension)

  • A format that determines how to interpret the data

  • A location in the file system

my_script.py      # Python source code (text)
data.csv          # Comma-separated values (text)
photo.jpg         # Image (binary)
document.pdf      # Portable Document Format (binary)

Text Files vs. Binary Files

Text FilesBinary Files

Human-readable

Not human-readable

Open in any text editor

Need specific programs

Line-based (usually)

Various structures

.txt, .py, .csv, .html, .json

.jpg, .pdf, .exe, .zip, .mp3

cat script.py     # Shows readable Python code
cat photo.jpg     # Shows garbage characters!

Python Files Are Text Files

Your .py files are just text files with Python code:

$ cat hello.py
print("Hello, world!")

$ python hello.py
Hello, world!

This means you can:

  • Edit them in any text editor

  • View them with cat or type

  • Create them with touch or echo

Try It: Create and Run a Python File

Use the terminal to create and run a simple Python script:

# Navigate to a good location
cd ~/Desktop

# Create a new file
echo 'print("Hello from the terminal!")' > hello.py

# Verify it was created
cat hello.py

# Run it
python hello.py

Work through this with a partner!

Putting It All Together

A Typical Python Workflow

# 1. Navigate to your project
cd ~/projects/inst326

# 2. Check what's there
ls

# 3. Create a new directory for today's work
mkdir week2

# 4. Move into it
cd week2

# 5. Create a new Python file
touch exercise.py

# 6. Edit it (opens your editor)
code exercise.py    # or nano, vim, etc.

# 7. Run your script
python exercise.py

Common Workflow Mistakes

ProblemSolution

"File not found" when running Python

Check you’re in the right directory (pwd, ls)

Created file in wrong location

Use mv to move it, or delete and recreate

Forgot where you saved something

Use find . -name "filename" to search

Typed wrong command

Press Up arrow to recall previous commands

Terminal Commands Reference

Mac/Linux Commands

NavigationFilesInfo

pwd - where am I

touch - create file

cat - show contents

ls - list files

mkdir - create folder

head - show start

cd - change dir

cp - copy

tail - show end

cd .. - go up

mv - move/rename

wc - word count

cd ~ - go home

rm - delete

man - manual

Windows Commands

NavigationFilesInfo

cd - where am I

New-Item - create file

type - show contents

dir - list files

mkdir - create folder

more - page through

cd - change dir

copy - copy

Get-Content

cd .. - go up

move - move/rename

help - manual

cd %USERPROFILE%

del - delete

--help flag

📋 Key Takeaways

Computer Architecture

CPU + Memory + Storage + I/O

Operating System

Manages hardware, runs programs, controls access

Terminal

Text interface for controlling your computer

File System

Hierarchical tree of directories and files

Paths

Absolute (from root) vs. Relative (from current)

Python Files

Just text files that Python interprets

Practice Challenge

Using only the terminal:

  1. Create a new directory called practice on your Desktop

  2. Navigate into it

  3. Create a file called greeting.py

  4. Use echo to write print("Hello, INST326!") into it

  5. Run the script with Python

  6. Verify it worked!

Work with a partner. Help each other debug!

Practice Challenge: Solution

# 1. Create directory
mkdir ~/Desktop/practice

# 2. Navigate into it
cd ~/Desktop/practice

# 3. Create file (touch creates empty, but we'll write directly)
# 4. Write the print statement
echo 'print("Hello, INST326!")' > greeting.py

# 5. Run it
python greeting.py

# 6. Verify
ls                 # Should show greeting.py
cat greeting.py    # Should show the print statement

Output:

Hello, INST326!

Questions?

🔗 Resources: